function initDatePicker() {
    var date = new Date();
    var endDate = date.toLocaleDateString();
    var startDate = getPreMonth(endDate);
    $('#report-range').daterangepicker({
        "locale": {
            "format": "YYYY/MM/DD",
            "separator": " - "
        },
        "startDate": startDate,
        "endDate": endDate,
        "maxDate": endDate
    }, function(start, end, label) {
        console.log(start.toISOString(), end.toISOString(), label);
    });
}

/* 获取上一个月
*
* @date 格式为yyyy-mm-dd的日期，如：2014-01-25
*/
function getPreMonth(date) {
   var arr = date.split('/');
   var year = arr[0]; //获取当前日期的年份
   var month = arr[1]; //获取当前日期的月份
   var day = arr[2]; //获取当前日期的日
   var days = new Date(year, month, 0);
   days = days.getDate(); //获取当前日期中月的天数
   var year2 = year;
   var month2 = parseInt(month) - 1;
   if (month2 == 0) {
       year2 = parseInt(year2) - 1;
       month2 = 12;
   }
   var day2 = day;
   var days2 = new Date(year2, month2, 0);
   days2 = days2.getDate();
   if (day2 > days2) {
       day2 = days2;
   }
   if (month2 < 10) {
       month2 = '0' + month2;
   }
   var t2 = year2 + '/' + month2 + '/' + day2;
   return t2;
}


/**
 * FormToJson
 */
(function($){
    $.fn.serializeJson=function(){
        var serializeObj={};
        var array=this.serializeArray();
        var str=this.serialize();
        $(array).each(function(){
            if(serializeObj[this.name]){
                if($.isArray(serializeObj[this.name])){
                    serializeObj[this.name].push(this.value);
                }else{
                    serializeObj[this.name]=[serializeObj[this.name],this.value];
                }
            }else{
                serializeObj[this.name]=this.value;
            }
        });
        return serializeObj;
    };
})(jQuery);